<?php 
	require_once ('jpgraph/src/jpgraph.php');
	require_once ('jpgraph/src/jpgraph_bar.php');
	require_once ('jpgraph/src/jpgraph_mgraph.php');


	// Some data
	$typegraph = $_REQUEST['type']; 
	$datay = unserialize($_REQUEST['tableauValeurs']);
	//$datay = array(0,1,4,18,32,21,14);
	//$datay=array(62,105,85,50);
	
	
	// Create the graph. These two calls are always required
	$graph = new Graph(550,220,'auto');
	$graph->SetScale("textlin");
	
	//$theme_class="DefaultTheme";
	//$graph->SetTheme(new $theme_class());
	
	// set major and minor tick positions manually
	$graph->SetBox(false);
	
	//$graph->ygrid->SetColor('gray');
	$graph->ygrid->SetFill(false);
	
	if ($typegraph == "spars") {
		$graph->xaxis->SetTickLabels(array('-3','-2','-1','Par','+1','+2','+3','4+'));
		$graph->title->Set("Statistiques Par (brut)");		
	}

	if ($typegraph == "sputts") {	
		$graph->xaxis->SetTickLabels(array('0','1','2','3','4+'));
		$graph->title->Set("Statistiques Putts");
	}
	
	$graph->yaxis->HideLine(false);
	$graph->yaxis->HideTicks(false,false);
	
	// Create the bar plots
	$b1plot = new BarPlot($datay);
	
	// ...and add it to the graPH
	$graph->Add($b1plot);
	
	
	$b1plot->SetColor("white");
	//$b1plot->SetFillGradient("#4B0082","white",GRAD_LEFT_REFLECTION);
	$b1plot->SetWidth(45);
	
	// Display the graph
	$graph->Stroke();
	
	/*
	
	// Some data
	$datay2=array(0,10,65,15,0);
	
	
	// Create the graph. These two calls are always required
	$graph2 = new Graph(550,220,'auto');
	$graph2->SetScale("textlin");
	
	//$theme_class="DefaultTheme";
	//$graph->SetTheme(new $theme_class());
	
	// set major and minor tick positions manually
	//$graph2->yaxis->SetTickPositions(array(0,10,20,30,40,50), array(5,15,25,35,45,55));
	$graph2->SetBox(false);
	
	//$graph->ygrid->SetColor('gray');
	$graph2->ygrid->SetFill(false);
	$graph2->xaxis->SetTickLabels(array('0','1','2','3','4+'));
	$graph2->yaxis->HideLine(false);
	$graph2->yaxis->HideTicks(false,false);
	
	// Create the bar plots
	$b2plot = new BarPlot($datay2);
	
	// ...and add it to the graPH
	$graph2->Add($b2plot);
	
	
	$b2plot->SetColor("white");
	//$b1plot->SetFillGradient("#4B0082","white",GRAD_LEFT_REFLECTION);
	$b2plot->SetWidth(45);
	$graph2->title->Set("Statistiques Putts");
	
	
	
	// Display the graph
	//$graph2->Stroke();
	
	
	//display both graphs
	$mgraph = new MGraph();
	$xpos1=3;$ypos1=3;
	$xpos2=3;$ypos2=300;
	$mgraph->Add($graph,$xpos1,$ypos1);
	$mgraph->Add($graph2,$xpos2,$ypos2);
	$mgraph->Stroke();
	
	*/
	?>
